home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / luff stuff / luff⁄updtht.c < prev    next >
Encoding:
Text File  |  1985-11-08  |  870 b   |  39 lines  |  [TEXT/MACA]

  1. # include "def.h"
  2.  
  3. /* Updates the threat board */
  4. updtht(who, x, y) char who; int x, y;{
  5.     short int t[5];
  6.     register int i;
  7.  
  8.     for(i = 0; i < 5; i++)
  9.         t[i] = 0;
  10.  
  11.     if(who == 'x')
  12.         who = 1;
  13.     else
  14.         who = 0;
  15.  
  16.     for(i = 0; i < 4; i++) /* Count threats in the four ways */
  17.         t[t_hvlr[i][who][x][y]]  += 1;
  18.  
  19.     thtcnt[who][threat[who][x][y]] -= 1;
  20.     threat[who][x][y] = 0;
  21.  
  22.     if((  t[1])                       /* 3 */
  23.       || (t[2]))                      /* stopped 4 */
  24.         threat[who][x][y] = 1;
  25.  
  26.     if(t[1] > 1)                      /* 3-3-combination */
  27.         threat[who][x][y] = 2;
  28.  
  29.     if(((t[2] > 0) && (t[1] > 0))     /* 4-3-combination */
  30.       || (t[2] > 1)                   /* 4-4-combination */
  31.       || (t[3] > 0))                  /* Free 4 */
  32.         threat[who][x][y] = 3;
  33.  
  34.     if(t[4] > 0)                      /* 5 = win */
  35.         threat[who][x][y] = 4;
  36.  
  37.     thtcnt[who][threat[who][x][y]] += 1;
  38. }
  39.